import { Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from "typeorm"
import { User } from "./User"

@Entity({
    name: 'id_card'
})
export class IdCard {
    @PrimaryGeneratedColumn()
    id: number

    @Column({
        length: 50,
        comment: '身份证号'
    })
    cardName: string


    // 和 user 表建议一对一关系
    @JoinColumn()
    @OneToOne(()=> User,{
        cascade:true ,       // 开启自动按照关联关系来保存  比如新增了user idcard  只需saveidcard实例 user实例会自动更新 
        onDelete:'CASCADE' , // 跟随删除
        onUpdate:'CASCADE'   // 跟随更新
    })
    user:User
}
